package com.bootmybatisdemo.demo.exception;

import com.bootmybatisdemo.demo.result.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

/**
 * Created with IntelliJ IDEA.
 * User: 朱雄
 * Date: 2021/05/26 9:43
 * Description:
 * Version: V1.0
 */
@ControllerAdvice
public class ExceptionCatch {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public AjaxResult resultNumberFormatException(){ //统一返回异常信息
        return AjaxResult.error("服务器错误");
    }

    @ExceptionHandler(MaxUploadSizeExceededException.class)
    @ResponseBody
    public AjaxResult resultMaxUploadSizeExceededException(){ //统一返回异常信息
        return AjaxResult.error("超出文件上传大小限制");
    }
}
